<div class="container" >
	<div class="row">
       <div class="col-sm-12">
           <h4 class="pull-left page-title"><b>NBIOT应用管理</b></h4>
           <ol class="breadcrumb pull-right">
               <li><a href="#">首页</a></li>
               <li ><a href="#/module/equView">设备列表</a></li>
               <li ><a href="#/module/equAdd">添加设备</a></li>
               <li class="active">应用管理</li>
           </ol>
       </div>
   </div>
	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-default">
				<div class="panel-body">
				<form role="form" class="form-horizontal" >
                        <div class="row">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <label  class="col-sm-1 control-label">应用ID：</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" ng-model="quereyData.appId" placeholder="模糊搜索">
                                </div>
                                <label  class="col-sm-2 control-label">应用名称：</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" ng-model="quereyData.appName" placeholder="模糊搜索">
                                </div>
                            </div>
                        </div>
                        <div class="form-group row-margin-top">
                            <div class="col-sm-5 col-md-offset-9 ">
	                             <button ng-if="user.competence != 4 " type="button" class="btn btn-primary waves-effect waves-light" data-toggle="modal" data-target="#equ-add-modal" ng-click="chkCmp == 2 ? seleCompetenceChg() : return">新增应用 <i class="fa fa-plus"></i></button>
                                <button  class="btn btn-primary waves-effect waves-light" type="submit"  btn-loading="loadCtl.search" ng-click="init()">搜索</button>
                                <button class="btn btn-default waves-effect" type="button" ng-click="resetSearch()">重置</button>
                            </div>
                        </div>
                    </form>
					<div class="row">
						<div class="col-md-12 col-sm-12 col-xs-12">
							<div class="table-responsive">
								<table class="table">
									<thead>
									<tr>
										<th>应用名称</th>
										<th>应用ID</th>
										<th>接入地址</th>
										<th>创建时间</th>
										<th>应用描述</th>
										<th>操作</th>
									</tr>
									</thead>
									<tbody>
									<tr ng-repeat="eqm in equipments"> 
									<td>{{ eqm.appName }}</td>
									<td>{{ eqm.appId }}</td>
									<td>{{ eqm.platformIp }}</td>
									<td>{{ eqm.createTime }}</td>
									<td>{{ eqm.remark }}</td>
									<td> 
										<a href="javascript:void(0)" data-toggle="modal" data-target="#equ-info-modal" ng-click="selEquInfo(eqm)" >详情 </a>
										<a href="javascript:void(0)" ng-if="user.competence != 4" data-toggle="modal" data-target="#reset-secret-modal" ng-click="selEquSecret(eqm.id)" >重置密匙</a>
										<a href="javascript:void(0)" ng-if="user.competence != 4" ng-click="delEqu(eqm.id)">删除</a>
										<a href="javascript:void(0)"  ng-click="subEquDataChg(eqm)"><span>订阅数据变化</span></a>
									</td>
									</tr>
									

									</tbody>
								</table>
							</div>
						</div>
						 <!-- 分页 -->
                        <page-info pages="pages" curpage="quereyData.page" change="changePage(page)"></page-info>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div id="equ-add-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="addEquModal" aria-hidden="true" style="display: none">
         <div class="modal-dialog"> 
             <div class="modal-content"> 
                 <div class="modal-header"> 
                     <button type="button" class="close" data-dismiss="modal" aria-hidden="true" ng-click="closeAddEquModal()">×</button> 
                     <h4 class="modal-title">添加应用</h4> 
                 </div> 
                 <form class="modal-body" ng-submit="addEqu()" name="addEquForm" novalidate="novalidate">
	               		<div class="row" ng-show="chkCmp == 2"> 
	                       <div class="col-md-12"> 
	                           <div class="form-group "> 
	                                <label  class="control-label">请选择应用所属客户<span style="color : red">*</span></label>  
	                                <select ng-if="chkCmp == 2" class="form-control" name="seleCompany"  ng-model="$parent.seleCompany" ng-options="x for (x, y) in selCompanys" required>
								</select>
	                           </div> 
	                       </div> 
	                   </div> 
                     <div class="row"> 
                         <div class="col-md-12"> 
                             <div class="form-group"> 
                                 <label  class="control-label">应用名称<span style="color : red">*</span></label> 
                                 <input type="text" class="form-control" ng-model="addApp.appName" required >
                             </div> 
                         </div> 
                        </div> 
                        <div class="row"> 
                            <div class="col-md-12"> 
                                <div class="form-group"> 
                                    <label  class="control-label">应用ID<span style="color : red">*</span></label> 
                                    <input type="text" class="form-control"  ng-model="addApp.appId" required  > 
                                </div> 
                            </div> 
                          </div> 
                        <div class="row">  
                         <div class="col-md-12"> 
                             <div class="form-group"> 
                                 <label  class="control-label">应用密钥<span style="color : red">*</span></label> 
                                 <input type="text" class="form-control"  ng-model="addApp.secret" required > 
                             </div> 
                         </div> 
                         </div> 
                        <div class="row">
                         <div class="col-md-12"> 
                             <div class="form-group"> 
                                 <label  class="control-label">应用接入地址<span style="color : red">*</span></label> 
                                 <input type="text" class="form-control"  ng-model="addApp.platformIp" required placeholder="不需要http，例：180.xxx.xxx.xx:xxxx" > 
                             </div> 
                         </div> 
                     </div> 
                      <div class="row"> 
	                        <div class="col-md-12"> 
	                            <div class="form-group no-margin"> 
	                                 <label  class="control-label">应用描述</label>  
	                                <textarea  class="form-control autogrow" ng-model="addApp.remark" style="overflow: hidden; word-wrap: break-word; resize: horizontal; height: 75px"></textarea> 
	                            </div> 
	                        </div> 
	                    </div>     
                 <div class="modal-footer"> 
                     <button id="close-add-equ-modal" type="button" class="btn btn-default waves-effect" data-dismiss="modal" ng-click="closeAddEquModal()" >关闭</button> 
                     <button type="submit" class="btn btn-info waves-effect waves-light"  ng-disabled="addEquForm.$invalid" btn-loading="loadCtl.addEnq">保存并添加</button> 
                 </div> 
                 </form> 
             </div> 
         </div>
     </div>
     
	<div id="reset-secret-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="resetSecretModal" aria-hidden="true" style="display: none">
         <div class="modal-dialog"> 
             <div class="modal-content"> 
                 <div class="modal-header"> 
                     <button type="button" class="close" data-dismiss="modal" aria-hidden="true" ng-click="closeSecretModal()">×</button> 
                     <h4 class="modal-title">重置密匙</h4> 
                 </div> 
                 <form class="modal-body" ng-submit="resetSecret()" name="resetSecretForm" novalidate="novalidate">
                        <div class="row">  
                         <div class="col-md-12"> 
                             <div class="form-group"> 
                                 <label  class="control-label">新应用密钥<span style="color : red">*</span></label> 
                                 <input type="text" class="form-control"  ng-model="appSecret.secret" required > 
                             </div> 
                         </div> 
                         </div> 
                 <div class="modal-footer"> 
                     <button id="close-reset-secret-modal" type="button" class="btn btn-default waves-effect" data-dismiss="modal" ng-click="closeSecretModal()" >关闭</button> 
                     <button type="submit" class="btn btn-info waves-effect waves-light"  ng-disabled="resetSecretForm.$invalid" btn-loading="loadCtl.resetSecret">保存</button> 
                 </div> 
                 </form> 
             </div> 
         </div>
     </div>
     
	<div id="equ-info-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="liteEquInfoModal" aria-hidden="true" style="display: none">
         <div class="modal-dialog"> 
             <div class="modal-content"> 
                 <div class="modal-header"> 
                     <button type="button" class="close" data-dismiss="modal" aria-hidden="true" ng-click="closeUpdateEquModal()">×</button> 
                     <h4 class="modal-title">应用详情</h4> 
                 </div> 
                 <form class="modal-body" ng-submit="updateEqu()" name="updateEquForm" novalidate="novalidate">
	               		<div class="row" ng-show="chkCmp == 2"> 
	                       <div class="col-md-12"> 
	                           <div class="form-group "> 
	                                <label  class="control-label">所属客户<span style="color : red">*</span></label>  
	                                <select ng-if="chkCmp == 2" class="form-control" ng-disabled="infoEditable" ng-model="$parent.currEqu.ownId" ng-options="x for (x, y) in selCompanys" required>
								</select>
	                           </div> 
	                       </div> 
	                   </div> 
                     <div class="row"> 
                         <div class="col-md-12"> 
                             <div class="form-group"> 
                                 <label  class="control-label">应用名称<span style="color : red">*</span></label> 
                                 <input type="text" class="form-control" ng-disabled="infoEditable" ng-model="currEqu.appName" required >
                             </div> 
                         </div> 
                        </div> 
                        <div class="row"> 
                            <div class="col-md-12"> 
                                <div class="form-group"> 
                                    <label  class="control-label">应用ID<span style="color : red">*</span></label> 
                                    <input type="text" class="form-control" ng-disabled="infoEditable" ng-model="currEqu.appId" required  > 
                                </div> 
                            </div> 
                          </div> 
                        <div class="row">
                         <div class="col-md-12"> 
                             <div class="form-group"> 
                                 <label  class="control-label">应用接入地址<span style="color : red">*</span></label> 
                                 <input type="text" class="form-control" ng-disabled="infoEditable" ng-model="currEqu.platformIp" required placeholder="不需要http，例：180.xxx.xxx.xx:xxxx" > 
                             </div> 
                         </div> 
                     </div> 
                      <div class="row"> 
	                        <div class="col-md-12"> 
	                            <div class="form-group no-margin"> 
	                                 <label  class="control-label">应用描述</label>  
	                                <textarea  class="form-control autogrow" ng-disabled="infoEditable" ng-model="currEqu.remark" style="overflow: hidden; word-wrap: break-word; resize: horizontal; height: 75px"></textarea> 
	                            </div> 
	                        </div> 
	                    </div>     
                 <div class="modal-footer"> 
                     <button id="close-info-equ-modal" type="button" class="btn btn-default waves-effect" data-dismiss="modal" ng-click="closeUpdateEquModal()" >{{chkCmp != 4 ? '关闭' : '确定'}}</button> 
                     <button type="button" class="btn btn-info waves-effect waves-light" ng-show="chkCmp != 4 && infoEditable" ng-click="chgEdit()" >编辑</button> 
                     <button type="submit" class="btn btn-info waves-effect waves-light" ng-show="chkCmp != 4 && !infoEditable" ng-disabled="updateEquForm.$invalid || !updateEquForm.$dirty" btn-loading="loadCtl.updEqu">保存</button> 
                 </div> 
                 </form> 
             </div> 
         </div>
     </div>
</div>